home *** CD-ROM | disk | FTP | other *** search
- GCC for RISC OS
- ---------------
-
- 0. Installation
- ------------
-
- The installation consists of:
-
- 1. RUN$Path must be extended with the directory name, which contains the
- GNU C executables. You can also copy them to your library directory.
-
- 2. Set the variable CPATH. This variable should contain the directories,
- which contain the header files. For instance:
-
- Set CPATH IDEFS::IDEDisc4.$.DesktopC.Clib
-
- CPATH can contain more than one directory name by using ';' seperators.
-
- For instance:
-
- If your header files are in $.clib.1.h and $.clib.2.h, CPATH must be
- set as follows:
-
- Set CPATH $.clib.1;$.clib.2
-
- You may also want to set the variables:
-
- C_INCLUDE_PATH
- CPLUS_INCLUDE_PATH
- OBJC_INCLUDE_PATH
- OBJCPLUS_INLCUDE_PATH
-
- CPLUS_INCLUDE_PATH and OBJCPLUS_INCLUDE_PATH will be only used during
- compiling c++ sources.
-
- 3. You may have to convert Stubs und RISC_OSlib.
-
- 4. You must set the variable mulib$Path to the FULL directory name where
- the risclib libraries can be found (e.g. stubsmu and oslib_mu). For
- instance:
-
- Set mulib$path IDEFS::IDEDisc4.$.Temp.GNU-CC.gcc2-3-3.risclib.
-
- The libraries can be found by calling Libraries mulib:stubsmu and
- mulib:oslib_mu
-
- 5. The documentation can be found in the 'doc' directory.
-
- 1. Prefixes in filenames
- ---------------------
-
- Unix expects, in contrary to RISC OS, that files types such as .c .o .cc
- are used as extension to the filename (e.g. myfile.c). GCC uses also all
- file names in this format. In order to behave correctly under RISC OS,
- GCC moves the file type extension to the start of the filename. For instance
- 'GCC sample.c' will be 'GCC c.sample'. Note: 'irgend.sample.c' will be
- 'c.irgend.sample'. GCC uses these extensions in order to find out the
- file type.
-
- The extensions have the following meaning:
-
- .c C Source
- .cc, .cxx, .C C++ Source (Note: only .cc can be used with RISC OS)
- .m objective-C Source (not yet supported)
- .o object file
- .h header file
- .i pre-processed file (cpp output)
- .ii pre-processed C++ file
- .s assembler source
- .S assembler source (needs pre-processing)
-
- 2. Options for GCC
- ---------------
-
- An exact explanation of the compiler options are given in the file 'invoke'
- in the doc directory. Most options are just like with other C compilers.
- You must not forget to use the -O or -O2 (optimizing) option. Without these
- options you will get less efficient code.
-
- Machine dependent options:
-
- -mno-apsc use the C-call convention for functions.
- -mcoproc Coprocessor is available (due to code optimizing,
- works also without one)
- -mpoke-function-name function names for post mortem debugger in code
-
- 3. Include files
- -------------
-
- For the include files is also the prefix-notation for file typen used. In
- the source code can the suffix-notation be used. The pre-processor converts
- these file names to prefix notation and recognizes the Unix directory paths.
- For instance /usr/include/sys/times.h becomes $.usr.include.sys.h.times,
- ../my-header.h becomes ^.h.my-header. The compiler recognizes only the
- file extensions .h und .c.
-
- Search order for include files:
-
- 1. current directory or the directories, which have been entered using
- the -I option
- 2. the directories, which are given by CPATH.
- 3. the directories given by C_INCLUDE_PATH (Standard C),
- CPLUS_INCLUDE_PATH (C++), OBJC_INCLUDE_PATH (Objective C) or
- OBJCPLUS_INLCUDE_PATH (Objective C++)
-
- The 'environment variables' may contain more directories (by using the
- ';' character as seperator). The Unix notation may also be used. However,
- different from RISC OS, the '.' or '/' character may not be the last
- character in direcory name (the Pre-Processor will do this for you). Also
- the '.h' must not be used in the path name.
-
- 4. Linker
- ------
-
- The linker must be called separately from the compiler (you must also
- use the -c option). In order to get 'absolute' code the linker must be
- called as follows:
-
- mulink -F -a32768 -osample -C o.sample1 o.sample2 mulib:stubsmu
- settype sample absolute
-
- Explanation:
-
- mulib$path contains the directory name where 'stubsmu' can be found.
-
- -F first object file must always be linked (only , when referenced).
- If stubsmu is linked, this option is not particulary necessary,
- because stubsmu has set the Obligatory-Link-Flag (will always be
- linked) and contains a reference to 'main'.
- -a32768 Absolute code with execution address &8000.
- -osample sample will be the output file (Note: no spaces)
- -C only the code, without header, publics, relocs.
-
- If the -a and -C options are not used, a object-file will be produced.
-
- Further options:
-
- -x a list of symbols, moduls and their addresses (e.g. offsets)
- will be given.
-
- -+ link C++ - code. The linker will search for symbol names in a
- C++ fashion and if they could not be found, they are converted
- into standard-C name. For instance:
-
- printf( "%d", 10 )
-
- generates in C++ a assembler call:
-
- ... bl printf__FPci
-
- If a symbol printf__FPci exists, the linker will generate a call
- to this symbol. Otherwise (with the -+ option) the name printf
- will be used (without __F...).
-
- -$<suffix> the characters, which in C++ symbol names is used between
- the 'normal' name of the function and the type. Default: __F.
- -u do not print a liste of undefined externals
-
- All other options are ignored by RISC OS version (have no meaning).
-
- Stubs MUST be linked before the RISC_OSlib is linked. The file which
- contains the function main MUST be linked first. In other cases the
- order of the object files doesn't matter. Objects which are not referenced
- by none of the other object files are simply ignored. For instance:
-
- mulink -F o.sample1 o.sample2 mulib:stubsmu
-
- o.sample2 will not be linked, if neither in mulib:stubsmu nor in o.sample1
- a function or variable from o.sample1 is referenced.
-
- If Stubs are linked, the following message could be printed:
-
- unresolved external(s)
- '__root_stack_size' in module 'Stub$$Code'
- '__RelocCode' in module 'Stub$$Code'
-
- Both references are in AOF-files as 'weak binding' defined and don't have
- to be declared. Applications will be linked correctly.
-
- If the RISC_OSlib is linked, the following message is printed:
-
- warning: double defined public variable(s):
-
- Simply ignore this :-)
-
- 5. AOFConvert
- ----------
-
- AOFConvert is a utility which converts object files in AOF-Format into
- the MUPROS format.
-
- You have to use it as follows:
-
- AOFConvert -l -osample o.sample
-
- The option -l suppresses all warnings (which are not interesting). During
- some circumstances you will also have to use the -O option. Then will the
- converted object ALWAYS be linked (if it is used somewhere in conjunction
- with MULINK, even if no reference is fullfilled).
-
- 6. Assembler
- ---------
-
- If you like to use the assembler, you are referred to the tex file (in the
- doc directory) and the RISC OS PRM's. The assembler is called by using:
-
- as -o o.sample s.sample
-
- A object file in MUPROS format will be generated. Note: assembler
- instructions must be lower case. Register names may be upper case or
- lower case. ARM/MUPROS specific pseudo-instructions:
-
- .objname <name> the just assembled object will be called
- <name> (Default: Dateiname)
- .segid <name> the segment ID becomes <name> (Default: 'code')
- .segattr <'RO'|'RW'> Read-only or Read-Write Segment (Default: 'RW')
-
- At the moment the assembler does not support separate code, data and null
- initialised segments (.text, .data, .bss), these will be assembled in
- different files.
-
- An example of a assembler source code is risclib.s.div-fast. More examples
- can be generated using GCC -O -S ...
-
- A full list of the assembler instructions (from the source code):
-
- /* format of the assembler string :
-
- %<bitfield>r print as an ARM register
- %<bitfield>f print a floating point constant if >7 else an
- fp register
- %c print condition code (always bits 28-31)
- %P print floating point precision in arithmetic insn
- %Q print floating point precision in ldf/stf insn
- %R print floating point rounding mode
- %<bitnum>'c print specified char iff bit is one
- %<bitnum>-<len>'c print specified char iff bit is one and length of
- command after c is at least len
- %<bitnum>`c print specified char iff bit is zero
- %<bitnum>?ab print a if bit is one else print b
- %p print 'p' iff bits 12-15 are 15
- %o print operand2 (immediate or register + shift)
- %a print address for ldr/str instruction
- %b print branch destination
- %A print address for ldc/stc/ldf/stf instruction
- %m print register mask for ldm/stm instruction
- %s print bits 0-23 as swi number/name
- %L print ldm type (fd, ea and the like ...)
- %S print stm type
- %r print adr operand
-
- /* ARM instructions */
-
- "mul%c%20's %16-19r,%0-3r,%8-11r",
- "mla%c%20's %16-19r,%0-3r,%8-11r,%12-15r",
- "and%c%20's %12-15r,%16-19r,%o",
- "eor%c%20's %12-15r,%16-19r,%o",
- "sub%c%20's %12-15r,%16-19r,%o",
- "rsb%c%20's %12-15r,%16-19r,%o",
- "add%c%20's %12-15r,%16-19r,%o",
- "adr%c%20's %12-15r,%r",
- "adc%c%20's %12-15r,%16-19r,%o",
- "sbc%c%20's %12-15r,%16-19r,%o",
- "rsc%c%20's %12-15r,%16-19r,%o",
- "tst%c%p %16-19r,%o",
- "teq%c%p %16-19r,%o",
- "cmp%c%p %16-19r,%o",
- "cmn%c%p %16-19r,%o",
- "orr%c%20's %12-15r,%16-19r,%o",
- "mov%c%20's %12-15r,%o",
- "bic%c%20's %12-15r,%16-19r,%o",
- "mvn%c%20's %12-15r,%o",
- "str%c%22'b %12-15r,%a",
- "ldr%c%22'b %12-15r,%a",
- "stm%c%S %16-19r%21'!,%m",
- "ldm%c%L %16-19r%21'!,%m%22'^",
- "b%24-2'l%c%24'l %b",
- "swi%c %s",
-
- /* Floating point coprocessor instructions */
-
- "adf%c%P%R %12-14f,%16-18f,%0-3f",
- "muf%c%P%R %12-14f,%16-18f,%0-3f",
- "suf%c%P%R %12-14f,%16-18f,%0-3f",
- "rsf%c%P%R %12-14f,%16-18f,%0-3f",
- "dvf%c%P%R %12-14f,%16-18f,%0-3f",
- "rdf%c%P%R %12-14f,%16-18f,%0-3f",
- "pow%c%P%R %12-14f,%16-18f,%0-3f",
- "rpw%c%P%R %12-14f,%16-18f,%0-3f",
- "rmf%c%P%R %12-14f,%16-18f,%0-3f",
- "fml%c%P%R %12-14f,%16-18f,%0-3f",
- "fdv%c%P%R %12-14f,%16-18f,%0-3f",
- "frd%c%P%R %12-14f,%16-18f,%0-3f",
- "pol%c%P%R %12-14f,%16-18f,%0-3f",
- "mvf%c%P%R %12-14f,%0-3f",
- "mnf%c%P%R %12-14f,%0-3f",
- "abs%c%P%R %12-14f,%0-3f",
- "rnd%c%P%R %12-14f,%0-3f",
- "sqt%c%P%R %12-14f,%0-3f",
- "log%c%P%R %12-14f,%0-3f",
- "lgn%c%P%R %12-14f,%0-3f",
- "exp%c%P%R %12-14f,%0-3f",
- "sin%c%P%R %12-14f,%0-3f",
- "cos%c%P%R %12-14f,%0-3f",
- "tan%c%P%R %12-14f,%0-3f",
- "asn%c%P%R %12-14f,%0-3f",
- "acs%c%P%R %12-14f,%0-3f",
- "atn%c%P%R %12-14f,%0-3f",
- "flt%c%P%R %16-18f,%12-15r",
- "fix%c%P%R %12-15r,%0-2f",
- "wfs%c %12-15r",
- "rfs%c %12-15r",
- "wfc%c %12-15r",
- "rfc%c %12-15r",
- "cmf%c %16-18f,%0-3f",
- "cnf%c %16-18f,%0-3f",
- "cmfe%c %16-18f,%0-3f",
- "cnfe%c %16-18f,%0-3f",
- "stf%c%Q %12-14f,%A",
- "ldf%c%Q %12-14f,%A",
-
- 6. Stubs / RISC_OSlib
- ------------------
-
- With the GNU C/C++ compiler, you should have also the converted versions
- of Stubs and RISC_OSlib (stubsmu and oslib_mu in the directory risclib).
- If this is not the case, you can generate these libraries by executing
- the Obey file risclib.makelibs.
-
- Again: link Stubs always before RISC_OSlib.
-
- 7. Your own libraries
- ------------------
-
- Libraries are constructed as follows:
-
- 1. compile single modules
- 2. put the objects in one file (e.g. using fappend)
-
- BTW:
-
- mulink .... o.sample1 o.sample2
-
- is exactly the same as:
-
- fappend o.sample1 o.sample2
- mulink .... o.sample1
-
- Note: if someone has written a number of functions or classes, which
- are very interesting: PLEASE let also other people use them. If this is
- the case, contact me. I will try to distribute them. I hope, other people
- will respond.
-
- 8. Objective C
- -----------
-
- The current RISC OS version of GNU C/C++ does not support objective C.
- If you have a need for this, please contact me.
-
- 9. "Support"
- ---------
-
- In many mailboxes you will find discussions about GNU C/C++. If you
- have access to Internet, for instance UUCP-News, you can read the newsgroup
- gnu.g++... For RISC OS specific problems I can be contacted at:
-
- Thomas Aeby
- Graeffet 406
- 1735 Giffers
- Schweiz
- Tel. 037 38 16 00
- EMail aeby@uropax.contrib.de
-
- 10. Source code
- -----------
-
- All source code of the compiler and the assembler are available from
- the address above.
-
- 11. Floating point arithmetic
- -------------------------
-
- Floating point arithmetic can be used. However, is not very well tested.
-
- 12. Memory
- ------
-
- In order to compile C++ programs, you will need more than 2Mb free memory
- (task slot). Standard C uses less memory, but you will still need about
- 1-1.2 Mb. Error messages like 'virtual memory exhausted' mean lack of
- memory.
-
- NOTE: gcc will not work under Virtual (by Nick Smith), because gcc
- calls the preprocessor and the 'real' compiler using the 'system' call.
- A solution is on its way.
-
- 13. Debugger
- --------
-
- Sorry, is not supported. On assembler level, you can (of course) make use
- of both !DDT and Debug. Source-Level-Debugging' is not supported.
-